import { useTable, LIST_TYPE } from '@crud/index';
import { getColonelUserlist } from '@/api/crm-agency/kgj/colonel';

// 查询
export const codeTypeOptions = [
  { label: '全部', value: -1 },
  { label: '老客户', value: 0 },
  { label: '新客户', value: 1 }
];
export const timeChange = (values:any[]) => {
  let from = undefined;
  let to = undefined;
  if (values && values.length > 0) {
    from = values[0];
    to = values[1];
  }
  return { from, to };
};
// 表格
export const useTableList = (options: any = {}) => {
  const columns: any = [
    { label: '客户昵称', prop: 'name', minWidth: 160, fixed: 'left' },
    { label: '手机号', prop: 'mobile', minWidth: 120 },
    { label: '客户类型', prop: 'is_new_order', minWidth: 120, render: (s: any) => s.row.is_new_order === 1 ? '新用户' : '老用户' },
    { label: '会员到期时间', prop: 'end_time', minWidth: 160, type: 'date' },
    { label: '关联时间', prop: 'complete_time', minWidth: 160, type: 'date' },
    { label: '购买次数', prop: 'buy_count', minWidth: 120 },
    { label: '备注', prop: 'remark', minWidth: 200, render: 'remark', align: 'center', fixed: 'right' }
  ];

  return useTable({
    ...options,
    type: LIST_TYPE.AGENCY,
    params: {
      key_word: undefined,
      gen_code: '',
      user_type: -1,
      product: -1,
      code_status: -1,
      from_dt: undefined,
      to_dt: undefined,
      complete_from_dt: undefined,
      complete_to_dt: undefined,
      _dateRange: [],
      _completeDateRange: []
    },
    columns: columns,
    getList: getColonelUserlist
  });
};
